var app = getApp()
var fileData = require('../../utils/data.js');
var req = require('../../utils/reqUtils.js');
var util = require('../../utils/util.js');


Page( {
  data: {
    addrIndex:0,
    date :'2016-10-14',
    time : '12:00',
    bookToastHidden:true,
    colors:fileData.getColor(0),
  },
  onLoad: function (options) {
    wx.setNavigationBarColor({
      frontColor: '#ffffff', // 必写项【该字体颜色仅支持 #ffffff 和 #000000 】
      backgroundColor: this.data.colors.topColor, // 传递的颜色值【仅支持有效值为十六进制颜色】
    })
    req.get('/carDetails/getCarDetails.do', {"carId":options.carId}, 1)
    .then(res => {
      this.setData({
       carDetail:res.data
      })
    }),

    req.get('/userAddress/getAddress.do', {"user":1}, 1)
    .then(res => {
      this.setData({
       address:util.formatAddress(res.data)
      })
    })
  },
  // 地址选择
  bindAddrPickerChange : function(e){
    console.log('Addrpicker发送选择改变，携带值为', e.detail.value)
    this.setData({
      addrIndex: e.detail.value
    })
  },
  
  bindToastTap:function(){
      console.log('预定成功')
      this.setData({
          bookToastHidden:false
      })
  },
  hideToast:function(){
    this.setData({
          bookToastHidden:true
      })
  },
  // 日期选择
  bindDateChange: function(e){
    console.log('date picker发送选择改变，携带值为', e.detail.value)
    this.setData({
          date: e.detail.value
    })
  },
  // 时间选择
  bindTimeChange: function(e){
    console.log('time picker发送选择改变，携带值为', e.detail.value)
    this.setData({
          time: e.detail.value
    })
  }
  
})